import { BasicColumn, FormSchema } from "/@/components/Table"
import { render } from "/@/utils/common/renderUtils"
import { rules } from "/@/utils/helper/validator"
import { DescItem } from "/@/components/Description/index"
import { UploadBizType } from "/@/enums/uploadEnum"
import DictEnum from "/@/enums/dictEnum"
export const columns: BasicColumn[] = [
  {
    title: "身份源",
    dataIndex: "logo",
    align: "left",
    width: 130,
    slot: 'logo'
  },
  {
    title: "描述",
    width: 240,
    dataIndex: "description",
    align: "left",
  },
  {
    title: "身份源类型",
    dataIndex: "type",
    width: 120,
    customRender: ({ text }) => {
      return render.renderTag(render.renderDict(text, DictEnum.ExtIdpType), "green")
    },
  },
  {
    title: "创建时间",
    dataIndex: "createdAt",
    sorter: true,
    width: 160,
  },
  {
    title: "创建者",
    dataIndex: "createdBy",
    sorter: true,
    width: 100,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "name",
    label: "名称",
    component: "Input",
    colProps: { span: 8 },
  },
  {
    field: "type",
    label: "类型",
    component: "JDictSelectTag",
    componentProps: {
      dictType: DictEnum.ExtIdpType,
      placeholder: "全部",
      chooseOptionLabel: "全部",
      stringToNumber: true,
    },
    colProps: { span: 8 },
  },
]

export const formSchema: FormSchema[] = [
  {
    field: "id",
    label: "id",
    component: "Input",
    show: false,
    required: false,
  },
  {
    field: "name",
    label: "名称",
    component: "Input",
    required: true,
  },
  {
    field: "code",
    label: "标识",
    component: "Input",
    required: true,
  },
  {
    label: "图标",
    field: "logo",
    component: "MyImageUpload",
    componentProps: {
      fileMax: 1,
      bizType: UploadBizType.GENERAL_IMAGE,
    },
  },
  {
    field: "type",
    label: "类型",
    defaultValue: "1",
    required: true,
    component: "JDictSelectTag",
    componentProps: {
      type: "radio",
      dictType: "ldp_type",
      placeholder: "请选择类型",
    },
  },
  {
    label: "描述",
    field: "description",
    component: "InputTextArea",
    componentProps: {
      placeholder: "请输入描述",
      rows: 3,
    },
  },
  {
    label: "备注",
    field: "remark",
    component: "InputTextArea",
    componentProps: {
      placeholder: "请输入备注",
      rows: 3,
    },
  },
]

export const formDetailSchema: DescItem[] = [
  {
    field: "name",
    label: "名称",
  },
  {
    field: "code",
    label: "标识",
  },
  {
    field: "logo",
    label: "图标",
    render: (curVal, data) => {
      return render.renderImagePreview({
        imageList: [{ src: curVal, width: 80 }],
      })
    },
  },

  {
    field: "type",
    label: "类型",
    render: (curVal, data) => {
      return render.renderTag(render.renderDict(curVal, "ldp_type"), "green")
    },
  },
  {
    field: "createdAt",
    label: "创建时间",
  },
  {
    field: "createdBy",
    label: "创建者",
  },
  {
    field: "updatedAt",
    label: "更新时间",
  },
  {
    field: "updatedBy",
    label: "更新者",
  },
  {
    field: "description",
    label: "描述",
  },
  {
    label: "备注",
    labelMinWidth: 40,
    field: "remark",
  },
]
